package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class ResponseServlet1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("ResponseServlet1...");
//        response.getWriter().write("haha"); // 这个会被忽略
//        response.setStatus(302); // 表示重定向
//        response.setHeader("Location","http://localhost:8080/05_web/responseServlet2"); // 重定向的地址
//        response.setHeader("Location", "https://www.baidu.com"); // 重定向的地址,可以访问当前工程以外的资源，但是不能访问当前工程WEB-INF下面的资源
        response.sendRedirect("/05_web/responseServlet2");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
